home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_glimpse.idb / usr / freeware / src / glimpse-3.0 / libtemplate / template / print-attr.c.z / print-attr.c
C/C++ Source or Header  |  1997-09-09  |  3KB  |  90 lines

  1. static char rcsid[] = "$Id: print-attr.c,v 1.9 1995/01/10 16:30:37 hardy Exp $";
  2. /*
  3.  *  print-attr - Reads in a template from stdin and prints the data
  4.  *  associated with the given attributed to stdout.
  5.  *
  6.  *  Darren Hardy, hardy@cs.colorado.edu, April 1994
  7.  *
  8.  *  ----------------------------------------------------------------------
  9.  *  Copyright (c) 1994, 1995.  All rights reserved.
  10.  *  
  11.  *          Mic Bowman of Transarc Corporation.
  12.  *          Peter Danzig of the University of Southern California.
  13.  *          Darren R. Hardy of the University of Colorado at Boulder.
  14.  *          Udi Manber of the University of Arizona.
  15.  *          Michael F. Schwartz of the University of Colorado at Boulder. 
  16.  *  
  17.  *  This copyright notice applies to all code in Harvest other than
  18.  *  subsystems developed elsewhere, which contain other copyright notices
  19.  *  in their source text.
  20.  *  
  21.  *  The Harvest software was developed by the Internet Research Task
  22.  *  Force Research Group on Resource Discovery (IRTF-RD).  The Harvest
  23.  *  software may be used for academic, research, government, and internal
  24.  *  business purposes without charge.  If you wish to sell or distribute
  25.  *  the Harvest software to commercial clients or partners, you must
  26.  *  license the software.  See
  27.  *  http://harvest.cs.colorado.edu/harvest/copyright,licensing.html#licensing.
  28.  *  
  29.  *  The Harvest software is provided ``as is'', without express or
  30.  *  implied warranty, and with no support nor obligation to assist in its
  31.  *  use, correction, modification or enhancement.  We assume no liability
  32.  *  with respect to the infringement of copyrights, trade secrets, or any
  33.  *  patents, and are not responsible for consequential damages.  Proper
  34.  *  use of the Harvest software is entirely the responsibility of the user.
  35.  *  
  36.  *  For those who are using Harvest for non-commercial purposes, you may
  37.  *  make derivative works, subject to the following constraints:
  38.  *  
  39.  *  - You must include the above copyright notice and these accompanying 
  40.  *    paragraphs in all forms of derivative works, and any documentation 
  41.  *    and other materials related to such distribution and use acknowledge 
  42.  *    that the software was developed at the above institutions.
  43.  *  
  44.  *  - You must notify IRTF-RD regarding your distribution of the 
  45.  *    derivative work.
  46.  *  
  47.  *  - You must clearly notify users that your are distributing a modified 
  48.  *    version and not the original Harvest software.
  49.  *  
  50.  *  - Any derivative product is also subject to the restrictions of the 
  51.  *    copyright, including distribution and use limitations.
  52.  */
  53. #include <stdio.h>
  54. #include <string.h>
  55. #include <time.h>
  56. #include "util.h"
  57. #include "template.h"
  58.  
  59. static void usage() 
  60. {
  61.     fprintf(stderr, "Usage: print-attr Attribute\n");
  62.     exit(1);
  63. }
  64.  
  65. int main(argc, argv)
  66. int argc;
  67. char *argv[];
  68. {
  69.     Template *template;
  70.     AVPair *avp;
  71.     char *attr;
  72.  
  73.     if (argc != 2) 
  74.         usage();
  75.  
  76.     attr = strdup(argv[1]);
  77.  
  78.     init_parse_template_file(stdin);
  79.     while ((template = parse_template()) != NULL) {
  80.         avp = extract_AVPair(template->list, attr);
  81.         if (avp) {
  82.             fwrite(avp->value, 1, avp->vsize, stdout);
  83.             putchar('\n');
  84.         }
  85.         free_template(template);    
  86.     }
  87.     finish_parse_template();
  88.     exit(0);
  89. }
  90.